home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 May
/
CMCD0505.ISO
/
Software
/
Demo
/
DesktopX
/
objects
/
ktekdockv1.dxpack
/
{50B76F56-7339-4DB8-B1B9-3CC5E35EA52D}.DXScript2
< prev
next >
Wrap
Extensible Markup Language
|
2004-08-24
|
4KB
|
168 lines
<?xml version="1.0"?>
<!--DXScript Data File. Version 2.0-->
<DXScript>
<Script><![CDATA[Dim decimal'whether or not a decimal point is part of the number
Dim operator'the currently active operator that will be applied to a calculation
Dim operand'the number that will be operated on by the displayed number
Dim operand2
Dim newoperand'whether to create a new number in the display if digits pressed
Dim newsum'whether a result has been calculated
Dim lastinputtype'operator or numerical
'Called when the script is executed
Sub Object_OnScriptEnter
decimal=0
operator="="
operand="0"
newoperand=False
newsum=True
lastinputtype="numeric"
desktopx.Object("kdockcalcop").text="[=]"
desktopx.Object("kdockcalcreadout").text="0"
End Sub
Sub calculate(k)
t=desktopx.Object("kdockcalcreadout").text
If instr(t,".")=False Then decimal=0
If (isnumeric(k) Or k="point" Or k="backspace") And newoperand Then
t="0"
newoperand=False
lastinputtype="numeric"
End If
If t="E" Then
t="0"
newoperand=False
lastinputtype="numeric"
desktopx.Object("kdockcalcreadout").text=t
End If
If k="" Then
Exit Sub
ElseIf k="esc" Then'reset everything for a new beginning!
decimal=0
operator="="
operand="0"
newoperand=False
newsum=True
lastinputtype="numeric"
desktopx.Object("kdockcalcop").text="[=]"
t="0"
ElseIf k="backspace" Then
If len(t)>1 Then
t=left(t,len(t)-1)
Else
t="0"
newoperand=False
End If
ElseIf k="point" Then
If decimal=1 Or len(t)>9+decimal Then Exit Sub
t=t&"."
decimal=1
ElseIf isnumeric(k) Then
If len(t)>9+decimal Then Exit Sub
lastinputtype="numeric"
If t="0" Then
t=Cstr(k)
Else
t=t&Cstr(k)
End If
Else'if k is one of the operator keys
operate(k)
Exit Sub
End If
desktopx.Object("kdockcalcreadout").text=t
End Sub
Sub operate(o)
t=Cdbl(desktopx.Object("kdockcalcreadout").text)
If o="enter" Then
If operator<>"=" And operand<>"" Then
dothesum
newsum=True
newoperand=True
operator="="
desktopx.Object("kdockcalcop").text="["&operator&"]"
End If
Exit Sub
Else
'desktopx.Object("temp").text="newoperand="&newoperand _
'&Chr(13)&"operand="&operand _
'&Chr(13)&"newsum="&newsum _
'&Chr(13)&"lastinputtype="&lastinputtype
If lastinputtype<>"operator" And newsum=False Then
dothesum
Else
operand=t
newsum=False
End If
If o="plus" Then
operator="+"
ElseIf o="minus" Then
operator="-"
ElseIf o="times" Then
operator="*"
ElseIf o="divide" Then
operator="/"
End If
End If
newoperand=True
lastinputtype="operator"
If operator="*" Then
desktopx.Object("kdockcalcop").text="[x]"
Else
desktopx.Object("kdockcalcop").text="["&operator&"]"
End If
End Sub
Sub dothesum
t=Cdbl(desktopx.Object("kdockcalcreadout").text)
If operator="+" Then
result=operand+t
ElseIf operator="-" Then
result=operand-t
ElseIf operator="*" Then
result=operand*t
ElseIf operator="/" Then
If t=0 Then
result="E"
Else
result=operand/t
End If
End If
desktopx.Object("kdockcalcreadout").text=result
operand=result
End Sub
Function Object_OnChar(key, extended)
Select Case key
Case 48 k=0
Case 49 k=1
Case 50 k=2
Case 51 k=3
Case 52 k=4
Case 53 k=5
Case 54 k=6
Case 55 k=7
Case 56 k=8
Case 57 k=9
Case 13 k="enter"
Case 27 k="esc"
Case 46 k="point"
Case 42
k="times"
Case 43
k="plus"
Case 45
k="minus"
Case 47
k="divide"
Case 8 k="backspace"
Case Else k=""
End Select
'desktopx.Object("kdockcalcop").text=key
calculate(k)
Object_OnChar = False
End Function
]]></Script><Globals><Editor><PropPane>0</PropPane><EditorLeft>270</EditorLeft><EditorTop>72</EditorTop><EditorRight>1048</EditorRight><EditorBottom>843</EditorBottom></Editor><Object><LanguageCLSID>{B54F3741-5B07-11CF-A4B0-00AA004A55E8}</LanguageCLSID><ControlCLSID>{00000000-0000-0000-0000-000000000000}</ControlCLSID><ControlObjWidth>64</ControlObjWidth><ControlObjHeight>64</ControlObjHeight><RunState>1</RunState><ManualControlLoad>0</ManualControlLoad><ScriptHostVersion>2</ScriptHostVersion></Object></Globals></DXScript>